优化投影管理文件夹已存在提示 - #6664
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce789a1ad8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| handler.reject(i18n("schematics.create_directory.failed", targetDir)); | ||
| } | ||
| }, "", new RequiredValidator(), new Validator(i18n("schematics.create_directory.failed.invalid_name"), FileUtils::isNameValid)); | ||
| }, "", new RequiredValidator(), new Validator(i18n("schematics.create_directory.failed.invalid_name"), FileUtils::isNameValid), new Validator(i18n("schematics.create_directory.failed.already_exists"), (it) -> !finalExistingFolders.contains(it))); |
There was a problem hiding this comment.
Recheck directory existence when submitting the name
The validator only checks a case-sensitive snapshot captured before the prompt opens. If another process creates the directory while the dialog is open, or on a case-insensitive filesystem the user enters different casing for an existing name, validation succeeds and Files.createDirectories(targetDir) silently accepts the already-existing directory; the dialog then resolves as though a new folder was created. Retain a live Files.exists(targetDir) check in the submission callback in addition to the interactive validator.
Useful? React with 👍 / 👎.
| i18n("schematics.create_directory.prompt"), | ||
| (result, handler) -> { | ||
| Path targetDir = parent.resolve(result); | ||
| if (Files.exists(targetDir)) { |
|
这么干的意义是什么呢( 原来的检查应该能胜任判断是否存在的功能吧? |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2a070ea8e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| try (var list = Files.list(parent)) { | ||
| existingFolders = list.map(Path::getFileName) | ||
| .map(Path::toString) | ||
| .collect(Collectors.toSet()); |
There was a problem hiding this comment.
Catch failures raised while consuming the directory stream
If directory enumeration fails after Files.list(parent) has returned—for example on a disconnected network share or removed device—the stream pipeline wraps that late I/O failure in UncheckedIOException, so this catch (IOException) is bypassed and the JavaFX action exits before opening the prompt. Catch UncheckedIOException as well so the intended empty-set fallback applies to traversal failures, not only failures while opening the stream.
Useful? React with 👍 / 👎.
|
我改改吧。 |
There was a problem hiding this comment.
Pull request overview
Adds proactive duplicate-folder validation to schematic directory creation.
Changes:
- Introduces a case-aware filename set utility.
- Validates directory names before submission.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
FileNameSet.java |
Adds filename collection and lookup support. |
SchematicsPage.java |
Adds duplicate-name validation to folder creation. |
Suppressed comments (1)
HMCLCore/src/main/java/org/jackhuang/hmcl/util/FileNameSet.java:42
- A
nullpredicate currently rejects every directory entry. The new caller passesnull, soexistingPathsis always empty and the added validator never shows the already-exists message while typing. Treatnullas “no filter.”
if (predicate != null && predicate.test(path)) {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4ae1e96aa2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (predicate != null && predicate.test(path)) { | ||
| set.add(path.getFileName().toString()); |
There was a problem hiding this comment.
Include every entry when the predicate is absent
When FileNameSet.list(parent, null) is called from SchematicsPage, this condition is false for every path, so the returned set is always empty and the new interactive already-exists validator never reports any existing name. Treat a null predicate as accepting all entries, while retaining the predicate check when one is supplied.
Useful? React with 👍 / 👎.
| boolean caseSensitive = OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS | ||
| && directory.getFileSystem() == FileSystems.getDefault(); |
There was a problem hiding this comment.
Correct the case-sensitivity selection
The flag is inverted relative to the filesystem behavior: a Windows default filesystem is treated as case-sensitive, while a typical Linux default filesystem is treated as case-insensitive. Once entries are populated, this allows differently cased duplicates through validation on Windows and incorrectly blocks distinct names such as Foo and foo on Linux.
Useful? React with 👍 / 👎.
No description provided.